from rich.console import Console
from rich.panel import Panel
from rich.prompt import Prompt
import time

console = Console()

def text_adventure():
    console.print(Panel("神秘洞穴探险", title_align="center"))
    choices = {
        "1": "点燃火把",
        "2": "悄悄前进",
        "3": "转身离开"
    }
    
    while True:
        console.print(Panel.fit("你进入黑暗洞穴，听到水流声。"))
        action = Prompt.ask(
            "[green]选择行动:[/green]\n1. 点燃火把\n2. 悄悄前进\n3. 离开",
            choices=list(choices.keys()),
            default="1"
        )
        
        if action == "1":
            console.print(Panel.fit("火光照亮墙壁，发现古老壁画！", style="gold"))
            break
        elif action == "2":
            console.print(Panel.fit("触发陷阱！", style="bold red"))
            return
        elif action == "3":
            console.print(Panel.fit("安全返回", style="dim green"))
            return

text_adventure()